package cn.school.controller.api;

import cn.hutool.http.server.HttpServerRequest;
import cn.school.api.service.ExternalInterfaceService;
import cn.school.common.api.CommonResult;
import cn.school.student.request.HttpRequest;
import cn.school.sys.entity.SysTenantInfo;
import cn.school.sys.service.SysTenantInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author: lx
 * @date: 2024/1/8 16:40
 * @description:
 */

@Api(tags = "对外接口")
@RestController
@RequestMapping("/external/interface")
public class ExternalInterfaceController {

    @Autowired
    ExternalInterfaceService externalInterfaceService;

    @Autowired
    SysTenantInfoService tenantInfoService;

    @ApiOperation("校门进出信息")
    @PostMapping("/receiveSchoolGateEntryAndExitInfo")
    public CommonResult receiveSchoolGateEntryAndExitInfo(@RequestBody List<Map<String, String>> records) throws ParseException {
        Boolean flag = externalInterfaceService.receiveSchoolGateEntryAndExitInfo(records);
        if (flag) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("宿舍打卡信息")
    @PostMapping("/receiveDormitoryCheckInfo")
    public CommonResult receiveDormitoryCheckInfo(@RequestBody List<Map<String, String>> records) {
        Boolean flag = externalInterfaceService.receiveDormitoryCheckInfo(records);
        if (flag) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("接收照片数据二次推送")
    @PostMapping("/receiveImgSecondPush")
    public CommonResult receiveImgSecondPush(@RequestBody List<Map<String, String>> records) {
        Boolean flag = externalInterfaceService.receiveImgSecondPush(records);
        if (flag) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("公话机调用接口 => 根据openId查询学生信息")
    @PostMapping("/getSomeInfoForOutByOpenId")
    public Map<String, Object> getSomeInfoForOutByOpenId(@RequestBody Map<String,String> param) {
        Map<String, Object> resultMap = externalInterfaceService.getSomeInfoForOutByOpenId(param);
        return resultMap;
    }

}

